/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upf.grupoe.p2ppicture.GUI;


import com.sun.media.jai.widget.DisplayJAI;
import edu.upf.grupoe.p2ppicture.DBAccessEngine.implementations.DBActionImpl;
import edu.upf.grupoe.p2ppicture.DBAccessEngine.implementations.DBActionResultImpl;
import edu.upf.grupoe.p2ppicture.DBAccessEngine.implementations.DBManagerImpl;
import edu.upf.grupoe.p2ppicture.Image.Implementations.EditorImpl;
import edu.upf.grupoe.p2ppicture.Image.Implementations.VisualizerImpl;
import edu.upf.grupoe.p2ppicture.SearchEngine.implementations.*;
import edu.upf.grupoe.p2ppicture.SearchEngine.interfaces.Constants;
import edu.upf.grupoe.p2ppicture.XMLstructure.implementations.ImageImpl;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.renderable.ParameterBlock;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.jai.InterpolationNearest;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;

    
/**
 * This class invokes a GUI for the project
 * @author marc
 */
public class P2PPictureClient extends javax.swing.JFrame implements Constants, PacketListener, Observer {

    /**
     * Creates new form GUI
     */
    private InstantMessageImpl IM;
    private static Log logger = LogFactory.getLog("Main");
    private List<String> SlideShowFiles;
    private PacketFilter filter = null;
    
    private EditorImpl ed = null;
    private int nUsers, nInbox, nReq;

    public P2PPictureClient() {
        initComponents();
        IM = InstantMessageImpl.getInstance();
        IM.addObserver(this);
        addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent e)
         {
           dispose();
           System.exit(0); //calling the method is a must
         }
        });
        setLocationRelativeTo(null);
        ed = new EditorImpl();
    }
    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        SearchBG = new javax.swing.ButtonGroup();
        JPEGDialog = new javax.swing.JDialog();
        SliderJPEGFactor = new javax.swing.JSlider();
        jLabel20 = new javax.swing.JLabel();
        CancelButtonJPEGQuality = new javax.swing.JButton();
        AcceptButtonJPEGQuality = new javax.swing.JButton();
        MainPanel = new javax.swing.JPanel();
        LoginPanel = new javax.swing.JPanel();
        MidPanel = new javax.swing.JPanel();
        LoginButton = new javax.swing.JButton();
        UserLabel = new javax.swing.JLabel();
        UserField = new javax.swing.JTextField();
        PasswordLabel = new javax.swing.JLabel();
        PasswordField = new javax.swing.JPasswordField();
        AccessLabel = new javax.swing.JLabel();
        RegisterLabel = new javax.swing.JLabel();
        RegisterPanel = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        SubmitButton = new javax.swing.JButton();
        Register = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        MainPagePanel = new javax.swing.JPanel();
        MainPageCP = new javax.swing.JPanel();
        SearchPanel = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        SearchContent = new javax.swing.JPanel();
        NormalSearchButton = new javax.swing.JRadioButton();
        AdvancedSearchButton = new javax.swing.JRadioButton();
        SearchField = new javax.swing.JTextField();
        SearchButton = new javax.swing.JButton();
        SearchLB = new javax.swing.JLabel();
        ResultsContentPanel = new javax.swing.JScrollPane();
        ResultsContentList = new javax.swing.JList();
        jSeparator1 = new javax.swing.JSeparator();
        ResultsLabel = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel59 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        ResultTP = new javax.swing.JTextPane();
        ResultThumbPanel = new javax.swing.JPanel();
        Owner = new javax.swing.JLabel();
        DownloadButton = new javax.swing.JButton();
        SearchProfileButton = new javax.swing.JButton();
        NewsRB = new javax.swing.JRadioButton();
        SearchContacts = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        ContactNameTF = new javax.swing.JTextField();
        ContactEmailTF = new javax.swing.JTextField();
        SearchContactButton = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        AddContact = new javax.swing.JButton();
        UserFoundListPane = new javax.swing.JScrollPane();
        UserFoundList = new javax.swing.JList();
        jLabel5 = new javax.swing.JLabel();
        ImagePanel = new javax.swing.JPanel();
        ImageTabbedPanel = new javax.swing.JTabbedPane();
        UploadTAB = new javax.swing.JPanel();
        SelectedImageLB = new javax.swing.JLabel();
        TagsTF = new javax.swing.JTextField();
        UploadBrowseButton = new javax.swing.JButton();
        TagsLB = new javax.swing.JLabel();
        OntologyLB = new javax.swing.JLabel();
        OntologyCB = new javax.swing.JComboBox();
        UploadButton = new javax.swing.JButton();
        SelectedImageTF = new javax.swing.JTextField();
        UploadImPanel = new javax.swing.JPanel();
        jLabel26 = new javax.swing.JLabel();
        uploadDescription = new javax.swing.JTextField();
        jLabel60 = new javax.swing.JLabel();
        AlbumTAB = new javax.swing.JPanel();
        jScrollPane10 = new javax.swing.JScrollPane();
        AlbumList = new javax.swing.JList();
        jLabel1 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        DeleteImageButton = new javax.swing.JButton();
        SlideshowButton = new javax.swing.JButton();
        AlbumThumbPanel = new javax.swing.JPanel();
        EditTAB = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        EditImageBrowseButton = new javax.swing.JButton();
        SaveButton = new javax.swing.JButton();
        DiscardChangeButton = new javax.swing.JButton();
        EditImageToolPanel = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        BlurSlider = new javax.swing.JSlider();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        HeightTF = new javax.swing.JTextField();
        WidthTF = new javax.swing.JTextField();
        ResizeButton = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        ContrastSlider = new javax.swing.JSlider();
        jLabel24 = new javax.swing.JLabel();
        JPEGSlider = new javax.swing.JSlider();
        jLabel25 = new javax.swing.JLabel();
        RotateTF = new javax.swing.JTextField();
        RotateButton = new javax.swing.JButton();
        SharpButton = new javax.swing.JButton();
        AdaptButton = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        ImageP = new javax.swing.JPanel();
        EditImageLabel = new javax.swing.JLabel();
        ProfilePanel = new javax.swing.JPanel();
        jTabbedPane3 = new javax.swing.JTabbedPane();
        MyProfile = new javax.swing.JPanel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        EditMyProfile = new javax.swing.JPanel();
        jLabel40 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jLabel46 = new javax.swing.JLabel();
        jLabel48 = new javax.swing.JLabel();
        jLabel50 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jTextField8 = new javax.swing.JTextField();
        jTextField9 = new javax.swing.JTextField();
        jTextField10 = new javax.swing.JTextField();
        jButton9 = new javax.swing.JButton();
        ContactProfile = new javax.swing.JPanel();
        jLabel43 = new javax.swing.JLabel();
        jLabel45 = new javax.swing.JLabel();
        jLabel47 = new javax.swing.JLabel();
        jLabel49 = new javax.swing.JLabel();
        jLabel51 = new javax.swing.JLabel();
        jLabel52 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        jLabel54 = new javax.swing.JLabel();
        jLabel55 = new javax.swing.JLabel();
        jLabel56 = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        jLabel58 = new javax.swing.JLabel();
        TransferPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        TransferRequestList = new javax.swing.JList();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        TransferAcceptButton = new javax.swing.JButton();
        TransferRefuseButton = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        DownloadingList = new javax.swing.JList();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        UploadingList = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        RequestUserList = new javax.swing.JList();
        ContactsPanel = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane12 = new javax.swing.JScrollPane();
        ContactsList = new javax.swing.JList();
        jButton10 = new javax.swing.JButton();
        jLabel41 = new javax.swing.JLabel();
        ChatSendButton = new javax.swing.JButton();
        jScrollPane13 = new javax.swing.JScrollPane();
        ChatBoard = new javax.swing.JTextArea();
        jScrollPane14 = new javax.swing.JScrollPane();
        TextToSend = new javax.swing.JEditorPane();
        MainPageSB = new javax.swing.JPanel();
        SearchButtonSB = new javax.swing.JButton();
        ImageButtonSB = new javax.swing.JButton();
        ContactsButtonSB = new javax.swing.JButton();
        TransferButtonSB = new javax.swing.JButton();
        ProfileButtonSB = new javax.swing.JButton();
        LogoutButtonSB = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JSeparator();

        SliderJPEGFactor.setMaximum(10);
        SliderJPEGFactor.setPaintLabels(true);
        SliderJPEGFactor.setPaintTicks(true);
        SliderJPEGFactor.setValue(5);

        jLabel20.setText("Choose the JPEG quality factor:");

        CancelButtonJPEGQuality.setText("Cancel");
        CancelButtonJPEGQuality.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelButtonJPEGQualityActionPerformed(evt);
            }
        });

        AcceptButtonJPEGQuality.setText("Accept");
        AcceptButtonJPEGQuality.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AcceptButtonJPEGQualityActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout JPEGDialogLayout = new javax.swing.GroupLayout(JPEGDialog.getContentPane());
        JPEGDialog.getContentPane().setLayout(JPEGDialogLayout);
        JPEGDialogLayout.setHorizontalGroup(
            JPEGDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(JPEGDialogLayout.createSequentialGroup()
                .addGroup(JPEGDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JPEGDialogLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(AcceptButtonJPEGQuality)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(CancelButtonJPEGQuality))
                    .addGroup(JPEGDialogLayout.createSequentialGroup()
                        .addGroup(JPEGDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(JPEGDialogLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel20))
                            .addGroup(JPEGDialogLayout.createSequentialGroup()
                                .addGap(35, 35, 35)
                                .addComponent(SliderJPEGFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        JPEGDialogLayout.setVerticalGroup(
            JPEGDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, JPEGDialogLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel20)
                .addGap(39, 39, 39)
                .addComponent(SliderJPEGFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(JPEGDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelButtonJPEGQuality)
                    .addComponent(AcceptButtonJPEGQuality))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("P2PPicture");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setFocusCycleRoot(false);
        setLocationByPlatform(true);
        setName("Frame");
        setResizable(false);

        MainPanel.setMinimumSize(new java.awt.Dimension(259, 133));
        MainPanel.setPreferredSize(new java.awt.Dimension(815, 400));
        MainPanel.setLayout(new java.awt.CardLayout());

        LoginPanel.setPreferredSize(new java.awt.Dimension(600, 380));
        LoginPanel.setLayout(new java.awt.GridBagLayout());

        MidPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        MidPanel.setMinimumSize(new java.awt.Dimension(275, 80));
        MidPanel.setPreferredSize(new java.awt.Dimension(320, 160));
        MidPanel.setLayout(new java.awt.GridBagLayout());

        LoginButton.setText("Login");
        LoginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 7;
        gridBagConstraints.insets = new java.awt.Insets(6, 10, 0, 5);
        MidPanel.add(LoginButton, gridBagConstraints);

        UserLabel.setText("User");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 12;
        gridBagConstraints.insets = new java.awt.Insets(0, 30, 0, 0);
        MidPanel.add(UserLabel, gridBagConstraints);

        UserField.setColumns(10);
        UserField.setText("p2ppicturetest");
        UserField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UserFieldActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        MidPanel.add(UserField, gridBagConstraints);

        PasswordLabel.setText("Password");
        PasswordLabel.setAlignmentY(1.0F);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 12;
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
        MidPanel.add(PasswordLabel, gridBagConstraints);

        PasswordField.setColumns(10);
        PasswordField.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        PasswordField.setText("p2ppicturetest");
        PasswordField.setMaximumSize(new java.awt.Dimension(10, 27));
        PasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                PasswordFieldKeyPressed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.insets = new java.awt.Insets(6, 5, 0, 0);
        MidPanel.add(PasswordField, gridBagConstraints);

        AccessLabel.setFont(new java.awt.Font("DejaVu Sans", 1, 12)); // NOI18N
        AccessLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        AccessLabel.setText("P2PPicture access with Google Account");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 13, 0);
        MidPanel.add(AccessLabel, gridBagConstraints);

        RegisterLabel.setFont(new java.awt.Font("DejaVu Sans", 1, 10)); // NOI18N
        RegisterLabel.setForeground(new java.awt.Color(0, 0, 255));
        RegisterLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        RegisterLabel.setText("Not yet registered? Click here to sign up!");
        RegisterLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        RegisterLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                RegisterLabelMouseClicked(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
        MidPanel.add(RegisterLabel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        LoginPanel.add(MidPanel, gridBagConstraints);

        MainPanel.add(LoginPanel, "LoginPanel");

        RegisterPanel.setLayout(new java.awt.GridBagLayout());

        jTextField1.setColumns(10);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
        RegisterPanel.add(jTextField1, gridBagConstraints);

        jTextField2.setColumns(10);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
        RegisterPanel.add(jTextField2, gridBagConstraints);

        jTextField3.setColumns(10);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 0);
        RegisterPanel.add(jTextField3, gridBagConstraints);

        jLabel9.setText("User");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 10);
        RegisterPanel.add(jLabel9, gridBagConstraints);

        jLabel10.setText("Google email");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 10);
        RegisterPanel.add(jLabel10, gridBagConstraints);

        jLabel11.setText("Password");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.insets = new java.awt.Insets(2, 0, 2, 10);
        RegisterPanel.add(jLabel11, gridBagConstraints);

        SubmitButton.setText("Sign up!");
        SubmitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SubmitButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.insets = new java.awt.Insets(2, 10, 2, 0);
        RegisterPanel.add(SubmitButton, gridBagConstraints);

        Register.setFont(new java.awt.Font("DejaVu Sans", 1, 18)); // NOI18N
        Register.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Register.setText("P2PPicture Register");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        RegisterPanel.add(Register, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
        RegisterPanel.add(jSeparator2, gridBagConstraints);

        MainPanel.add(RegisterPanel, "RegisterPanel");

        MainPagePanel.setMinimumSize(new java.awt.Dimension(0, 0));
        MainPagePanel.setPreferredSize(new java.awt.Dimension(815, 475));

        MainPageCP.setPreferredSize(new java.awt.Dimension(699, 475));
        MainPageCP.setLayout(new java.awt.CardLayout());

        SearchPanel.setPreferredSize(new java.awt.Dimension(665, 475));

        SearchBG.add(NormalSearchButton);
        NormalSearchButton.setSelected(true);
        NormalSearchButton.setText("Picture Search");

        SearchBG.add(AdvancedSearchButton);
        AdvancedSearchButton.setText("Advanced Search");

        SearchField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                SearchFieldKeyPressed(evt);
            }
        });

        SearchButton.setText("Search");
        SearchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonActionPerformed(evt);
            }
        });

        SearchLB.setText("Your Search");

        ResultsContentList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                ResultsContentListValueChanged(evt);
            }
        });
        ResultsContentPanel.setViewportView(ResultsContentList);

        ResultsLabel.setText("Results");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ontology 1", "Ontology 2", "Ontology 3", "Ontology 4", "Ontology 5" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel2.setText("Result thumbnail");

        jLabel23.setText("Owner");

        jLabel59.setText("Description");

        jScrollPane7.setViewportView(ResultTP);

        ResultThumbPanel.setMaximumSize(new java.awt.Dimension(120, 150));
        ResultThumbPanel.setMinimumSize(new java.awt.Dimension(120, 150));
        ResultThumbPanel.setPreferredSize(new java.awt.Dimension(120, 150));

        javax.swing.GroupLayout ResultThumbPanelLayout = new javax.swing.GroupLayout(ResultThumbPanel);
        ResultThumbPanel.setLayout(ResultThumbPanelLayout);
        ResultThumbPanelLayout.setHorizontalGroup(
            ResultThumbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 120, Short.MAX_VALUE)
        );
        ResultThumbPanelLayout.setVerticalGroup(
            ResultThumbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 150, Short.MAX_VALUE)
        );

        DownloadButton.setText("Download");
        DownloadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DownloadButtonActionPerformed(evt);
            }
        });

        SearchProfileButton.setText("Profile");
        SearchProfileButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchProfileButtonActionPerformed(evt);
            }
        });

        SearchBG.add(NewsRB);
        NewsRB.setText("News Search");
        NewsRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewsRBActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout SearchContentLayout = new javax.swing.GroupLayout(SearchContent);
        SearchContent.setLayout(SearchContentLayout);
        SearchContentLayout.setHorizontalGroup(
            SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SearchContentLayout.createSequentialGroup()
                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SearchContentLayout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(SearchLB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(SearchContentLayout.createSequentialGroup()
                                .addComponent(SearchField, javax.swing.GroupLayout.PREFERRED_SIZE, 411, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(SearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(SearchContentLayout.createSequentialGroup()
                                .addComponent(NormalSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(NewsRB)
                                .addGap(40, 40, 40)
                                .addComponent(AdvancedSearchButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(SearchContentLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator1)
                            .addGroup(SearchContentLayout.createSequentialGroup()
                                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(ResultsLabel)
                                    .addComponent(ResultsContentPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel59))
                                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(SearchContentLayout.createSequentialGroup()
                                        .addGap(11, 11, 11)
                                        .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SearchContentLayout.createSequentialGroup()
                                                .addComponent(DownloadButton)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(SearchProfileButton))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, SearchContentLayout.createSequentialGroup()
                                                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel23)
                                                    .addComponent(ResultThumbPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel2))
                                                .addGap(28, 28, 28))))
                                    .addGroup(SearchContentLayout.createSequentialGroup()
                                        .addGap(18, 18, 18)
                                        .addComponent(Owner, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                .addContainerGap())
        );
        SearchContentLayout.setVerticalGroup(
            SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SearchContentLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SearchLB, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SearchField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SearchButton))
                .addGap(1, 1, 1)
                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(NormalSearchButton)
                    .addComponent(AdvancedSearchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(NewsRB))
                .addGap(42, 42, 42)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ResultsLabel)
                    .addComponent(jLabel59)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(SearchContentLayout.createSequentialGroup()
                        .addComponent(ResultThumbPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Owner, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(42, 42, 42)
                        .addGroup(SearchContentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DownloadButton)
                            .addComponent(SearchProfileButton)))
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ResultsContentPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Content", SearchContent);

        java.awt.GridBagLayout SearchContactsLayout = new java.awt.GridBagLayout();
        SearchContactsLayout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0};
        SearchContactsLayout.rowHeights = new int[] {0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0};
        SearchContacts.setLayout(SearchContactsLayout);

        jLabel13.setText("Name");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        SearchContacts.add(jLabel13, gridBagConstraints);

        jLabel14.setText("email");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        SearchContacts.add(jLabel14, gridBagConstraints);

        ContactNameTF.setColumns(10);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        SearchContacts.add(ContactNameTF, gridBagConstraints);

        ContactEmailTF.setColumns(10);
        ContactEmailTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ContactEmailTFActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        SearchContacts.add(ContactEmailTF, gridBagConstraints);

        SearchContactButton.setText("Search");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(8, 83, 0, 0);
        SearchContacts.add(SearchContactButton, gridBagConstraints);

        jLabel15.setText("Users found:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        SearchContacts.add(jLabel15, gridBagConstraints);

        AddContact.setText("Add to contact's list");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 26;
        gridBagConstraints.gridy = 26;
        SearchContacts.add(AddContact, gridBagConstraints);

        UserFoundListPane.setPreferredSize(new java.awt.Dimension(200, 350));

        UserFoundList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "User 1", "User 2", "User 3", "User 4", "User 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        UserFoundList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        UserFoundList.setAutoscrolls(false);
        UserFoundList.setMaximumSize(new java.awt.Dimension(200, 350));
        UserFoundList.setPreferredSize(new java.awt.Dimension(200, 350));
        UserFoundList.setSelectedIndex(0);
        UserFoundListPane.setViewportView(UserFoundList);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 23;
        gridBagConstraints.gridheight = 21;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
        SearchContacts.add(UserFoundListPane, gridBagConstraints);

        jLabel5.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel5.setText("Contacts search in P2PPicture ");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 0);
        SearchContacts.add(jLabel5, gridBagConstraints);

        jTabbedPane1.addTab("Contacts", SearchContacts);

        javax.swing.GroupLayout SearchPanelLayout = new javax.swing.GroupLayout(SearchPanel);
        SearchPanel.setLayout(SearchPanelLayout);
        SearchPanelLayout.setHorizontalGroup(
            SearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1)
        );
        SearchPanelLayout.setVerticalGroup(
            SearchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(SearchPanelLayout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        MainPageCP.add(SearchPanel, "SearchPanel");

        ImageTabbedPanel.setMinimumSize(new java.awt.Dimension(0, 0));
        ImageTabbedPanel.setPreferredSize(new java.awt.Dimension(674, 475));

        UploadTAB.setMinimumSize(new java.awt.Dimension(0, 0));
        UploadTAB.setPreferredSize(new java.awt.Dimension(694, 450));

        SelectedImageLB.setText("Selected Image");

        TagsTF.setColumns(15);
        TagsTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TagsTFActionPerformed(evt);
            }
        });

        UploadBrowseButton.setText("Browse...");
        UploadBrowseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UploadBrowseButtonActionPerformed(evt);
            }
        });

        TagsLB.setText("Tags");

        OntologyLB.setText("Ontology");

        OntologyCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        UploadButton.setText("Upload");
        UploadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UploadButtonActionPerformed(evt);
            }
        });

        SelectedImageTF.setColumns(10);

        UploadImPanel.setMinimumSize(new java.awt.Dimension(0, 0));
        UploadImPanel.setPreferredSize(new java.awt.Dimension(200, 200));
        UploadImPanel.setLayout(new java.awt.BorderLayout());

        jLabel26.setText("Thumbnail");

        jLabel60.setText("Description");

        javax.swing.GroupLayout UploadTABLayout = new javax.swing.GroupLayout(UploadTAB);
        UploadTAB.setLayout(UploadTABLayout);
        UploadTABLayout.setHorizontalGroup(
            UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(UploadTABLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(UploadTABLayout.createSequentialGroup()
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(UploadTABLayout.createSequentialGroup()
                                .addComponent(SelectedImageLB)
                                .addGap(5, 5, 5)
                                .addComponent(SelectedImageTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(5, 5, 5)
                                .addComponent(UploadBrowseButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(TagsLB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, UploadTABLayout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel60)
                                    .addComponent(OntologyLB))
                                .addGap(5, 5, 5)))
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(TagsTF)
                            .addComponent(OntologyCB, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(UploadTABLayout.createSequentialGroup()
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(UploadImPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel26))
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(UploadTABLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(UploadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(UploadTABLayout.createSequentialGroup()
                                .addGap(174, 174, 174)
                                .addComponent(uploadDescription)))))
                .addGap(152, 152, 152))
        );
        UploadTABLayout.setVerticalGroup(
            UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(UploadTABLayout.createSequentialGroup()
                .addGap(108, 108, 108)
                .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(SelectedImageLB, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(UploadTABLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(SelectedImageTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(UploadBrowseButton)
                    .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(TagsLB, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(TagsTF, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(UploadTABLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(UploadImPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(UploadTABLayout.createSequentialGroup()
                                .addGap(51, 51, 51)
                                .addComponent(UploadButton))))
                    .addGroup(UploadTABLayout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(OntologyLB, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(OntologyCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(UploadTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(uploadDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel60))))
                .addContainerGap(66, Short.MAX_VALUE))
        );

        ImageTabbedPanel.addTab("Upload", UploadTAB);
        UploadTAB.getAccessibleContext().setAccessibleParent(ImageTabbedPanel);

        AlbumTAB.setPreferredSize(new java.awt.Dimension(674, 450));

        AlbumList.setValueIsAdjusting(true);
        AlbumList.setVerifyInputWhenFocusTarget(false);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, AlbumList, org.jdesktop.beansbinding.ELProperty.create("${selectedElements}"), AlbumList, org.jdesktop.beansbinding.BeanProperty.create("selectedElements"));
        bindingGroup.addBinding(binding);

        AlbumList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                AlbumListValueChanged(evt);
            }
        });
        jScrollPane10.setViewportView(AlbumList);

        jLabel1.setText("Pictures");

        jLabel27.setText("Thumbnail");

        DeleteImageButton.setText("Delete picture");
        DeleteImageButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteImageButtonActionPerformed(evt);
            }
        });

        SlideshowButton.setText("Slideshow");
        SlideshowButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SlideshowButtonActionPerformed(evt);
            }
        });

        AlbumThumbPanel.setMinimumSize(new java.awt.Dimension(300, 300));
        AlbumThumbPanel.setPreferredSize(new java.awt.Dimension(300, 300));

        javax.swing.GroupLayout AlbumThumbPanelLayout = new javax.swing.GroupLayout(AlbumThumbPanel);
        AlbumThumbPanel.setLayout(AlbumThumbPanelLayout);
        AlbumThumbPanelLayout.setHorizontalGroup(
            AlbumThumbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        AlbumThumbPanelLayout.setVerticalGroup(
            AlbumThumbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout AlbumTABLayout = new javax.swing.GroupLayout(AlbumTAB);
        AlbumTAB.setLayout(AlbumTABLayout);
        AlbumTABLayout.setHorizontalGroup(
            AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AlbumTABLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(AlbumThumbPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(DeleteImageButton)
                    .addComponent(SlideshowButton)
                    .addComponent(jLabel27))
                .addGap(0, 7, Short.MAX_VALUE))
        );
        AlbumTABLayout.setVerticalGroup(
            AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(AlbumTABLayout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel27))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(AlbumTABLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(AlbumTABLayout.createSequentialGroup()
                        .addComponent(AlbumThumbPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(DeleteImageButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(SlideshowButton)))
                .addContainerGap(49, Short.MAX_VALUE))
        );

        ImageTabbedPanel.addTab("Album", AlbumTAB);
        AlbumTAB.getAccessibleContext().setAccessibleParent(ImageTabbedPanel);

        EditTAB.setMinimumSize(new java.awt.Dimension(0, 0));
        EditTAB.setPreferredSize(new java.awt.Dimension(674, 450));
        java.awt.GridBagLayout EditTABLayout1 = new java.awt.GridBagLayout();
        EditTABLayout1.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0};
        EditTABLayout1.rowHeights = new int[] {0, 3, 0, 3, 0, 3, 0};
        EditTAB.setLayout(EditTABLayout1);

        jLabel19.setText("Select an image:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        EditTAB.add(jLabel19, gridBagConstraints);

        EditImageBrowseButton.setText("Browse");
        EditImageBrowseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditImageBrowseButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditTAB.add(EditImageBrowseButton, gridBagConstraints);

        SaveButton.setText("Save");
        SaveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
        EditTAB.add(SaveButton, gridBagConstraints);

        DiscardChangeButton.setText("Discard");
        DiscardChangeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DiscardChangeButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
        EditTAB.add(DiscardChangeButton, gridBagConstraints);

        EditImageToolPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        java.awt.GridBagLayout EditImageToolPanelLayout = new java.awt.GridBagLayout();
        EditImageToolPanelLayout.columnWidths = new int[] {0, 5, 0, 5, 0};
        EditImageToolPanelLayout.rowHeights = new int[] {0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0};
        EditImageToolPanel.setLayout(EditImageToolPanelLayout);

        jLabel3.setText("Blur");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.gridwidth = 5;
        EditImageToolPanel.add(jLabel3, gridBagConstraints);

        jLabel12.setText("Sharpening");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.gridwidth = 3;
        EditImageToolPanel.add(jLabel12, gridBagConstraints);

        BlurSlider.setMajorTickSpacing(1);
        BlurSlider.setMaximum(2);
        BlurSlider.setMinorTickSpacing(1);
        BlurSlider.setPaintTicks(true);
        BlurSlider.setSnapToTicks(true);
        BlurSlider.setValue(0);
        BlurSlider.setPreferredSize(new java.awt.Dimension(150, 50));
        BlurSlider.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                BlurSliderMouseReleased(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 7);
        EditImageToolPanel.add(BlurSlider, gridBagConstraints);

        jLabel16.setText("% Width");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 0);
        EditImageToolPanel.add(jLabel16, gridBagConstraints);

        jLabel17.setText("% Height");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.weighty = 0.6;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 0);
        EditImageToolPanel.add(jLabel17, gridBagConstraints);

        HeightTF.setColumns(3);
        HeightTF.setText("100");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 2.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 7);
        EditImageToolPanel.add(HeightTF, gridBagConstraints);

        WidthTF.setColumns(3);
        WidthTF.setText("100");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 2.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 7);
        EditImageToolPanel.add(WidthTF, gridBagConstraints);

        ResizeButton.setText("Resize");
        ResizeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResizeButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 22;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 7);
        EditImageToolPanel.add(ResizeButton, gridBagConstraints);

        jLabel18.setText("Contrast");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 5;
        EditImageToolPanel.add(jLabel18, gridBagConstraints);

        ContrastSlider.setMajorTickSpacing(1);
        ContrastSlider.setMaximum(2);
        ContrastSlider.setMinimum(-2);
        ContrastSlider.setPaintTicks(true);
        ContrastSlider.setSnapToTicks(true);
        ContrastSlider.setValue(0);
        ContrastSlider.setPreferredSize(new java.awt.Dimension(150, 50));
        ContrastSlider.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                ContrastSliderMouseReleased(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 7, 0, 4);
        EditImageToolPanel.add(ContrastSlider, gridBagConstraints);

        jLabel24.setText("JPEG quality");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 36;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
        EditImageToolPanel.add(jLabel24, gridBagConstraints);

        JPEGSlider.setMajorTickSpacing(20);
        JPEGSlider.setMinorTickSpacing(10);
        JPEGSlider.setPaintTicks(true);
        JPEGSlider.setSnapToTicks(true);
        JPEGSlider.setPreferredSize(new java.awt.Dimension(150, 50));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 38;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        EditImageToolPanel.add(JPEGSlider, gridBagConstraints);

        jLabel25.setText("Rotation");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 26;
        EditImageToolPanel.add(jLabel25, gridBagConstraints);

        RotateTF.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 26;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 7);
        EditImageToolPanel.add(RotateTF, gridBagConstraints);

        RotateButton.setText("Rotate");
        RotateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RotateButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 28;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 7);
        EditImageToolPanel.add(RotateButton, gridBagConstraints);

        SharpButton.setText("Sharp");
        SharpButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SharpButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 14;
        EditImageToolPanel.add(SharpButton, gridBagConstraints);

        AdaptButton.setText("Adapt");
        AdaptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AdaptButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 32;
        EditImageToolPanel.add(AdaptButton, gridBagConstraints);

        jLabel6.setText("Zoom");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 32;
        gridBagConstraints.gridwidth = 3;
        EditImageToolPanel.add(jLabel6, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.weightx = 0.5;
        gridBagConstraints.weighty = 1.0;
        EditTAB.add(EditImageToolPanel, gridBagConstraints);

        ImageP.setLayout(new java.awt.BorderLayout());
        jScrollPane3.setViewportView(ImageP);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.gridheight = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 6.0;
        gridBagConstraints.weighty = 2.0;
        EditTAB.add(jScrollPane3, gridBagConstraints);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        EditTAB.add(EditImageLabel, gridBagConstraints);

        ImageTabbedPanel.addTab("Editor", EditTAB);
        EditTAB.getAccessibleContext().setAccessibleParent(ImageTabbedPanel);

        javax.swing.GroupLayout ImagePanelLayout = new javax.swing.GroupLayout(ImagePanel);
        ImagePanel.setLayout(ImagePanelLayout);
        ImagePanelLayout.setHorizontalGroup(
            ImagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ImageTabbedPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 699, Short.MAX_VALUE)
        );
        ImagePanelLayout.setVerticalGroup(
            ImagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ImageTabbedPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        MainPageCP.add(ImagePanel, "ImagePanel");

        ProfilePanel.setPreferredSize(new java.awt.Dimension(665, 475));

        java.awt.GridBagLayout jPanel2Layout1 = new java.awt.GridBagLayout();
        jPanel2Layout1.columnWidths = new int[] {0, 5, 0};
        jPanel2Layout1.rowHeights = new int[] {0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0};
        MyProfile.setLayout(jPanel2Layout1);

        jLabel28.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel28.setText("Name:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel28, gridBagConstraints);

        jLabel29.setText("Marc");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel29, gridBagConstraints);

        jLabel30.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel30.setText("Last name:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel30, gridBagConstraints);

        jLabel31.setText("Font");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel31, gridBagConstraints);

        jLabel32.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel32.setText("Email:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel32, gridBagConstraints);

        jLabel33.setText("mfont44@gmail.com");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel33, gridBagConstraints);

        jLabel34.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel34.setText("Telephone:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel34, gridBagConstraints);

        jLabel35.setText("934146566");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel35, gridBagConstraints);

        jLabel36.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel36.setText("Pictures:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel36, gridBagConstraints);

        jLabel37.setText("4");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel37, gridBagConstraints);

        jLabel38.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel38.setText("Company:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel38, gridBagConstraints);

        jLabel39.setText("Knóos");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        MyProfile.add(jLabel39, gridBagConstraints);

        jTabbedPane3.addTab("My profile", MyProfile);

        java.awt.GridBagLayout jPanel3Layout = new java.awt.GridBagLayout();
        jPanel3Layout.columnWidths = new int[] {0, 5, 0, 5, 0};
        jPanel3Layout.rowHeights = new int[] {0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0};
        EditMyProfile.setLayout(jPanel3Layout);

        jLabel40.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel40.setText("Name:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel40, gridBagConstraints);

        jLabel42.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel42.setText("Last name:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel42, gridBagConstraints);

        jLabel44.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel44.setText("Email:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel44, gridBagConstraints);

        jLabel46.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel46.setText("Telephone:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel46, gridBagConstraints);

        jLabel48.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel48.setText("Pictures:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel48, gridBagConstraints);

        jLabel50.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel50.setText("Company:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        EditMyProfile.add(jLabel50, gridBagConstraints);

        jTextField5.setColumns(10);
        jTextField5.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        EditMyProfile.add(jTextField5, gridBagConstraints);

        jTextField6.setColumns(10);
        jTextField6.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        EditMyProfile.add(jTextField6, gridBagConstraints);

        jTextField7.setColumns(10);
        jTextField7.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        EditMyProfile.add(jTextField7, gridBagConstraints);

        jTextField8.setColumns(10);
        jTextField8.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 6;
        EditMyProfile.add(jTextField8, gridBagConstraints);

        jTextField9.setColumns(10);
        jTextField9.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 8;
        EditMyProfile.add(jTextField9, gridBagConstraints);

        jTextField10.setColumns(10);
        jTextField10.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 10;
        EditMyProfile.add(jTextField10, gridBagConstraints);

        jButton9.setText("Save changes");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 12;
        EditMyProfile.add(jButton9, gridBagConstraints);

        jTabbedPane3.addTab("Edit my profile", EditMyProfile);

        jLabel43.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel43.setText("Name:");

        jLabel45.setText("Ariadna");

        jLabel47.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel47.setText("Last name:");

        jLabel49.setText("Font");

        jLabel51.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel51.setText("Email:");

        jLabel52.setText("afont44@gmail.com");

        jLabel53.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel53.setText("Telephone:");

        jLabel54.setText("934146566");

        jLabel55.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel55.setText("Pictures:");

        jLabel56.setText("4");

        jLabel57.setFont(new java.awt.Font("DejaVu Sans", 1, 13)); // NOI18N
        jLabel57.setText("Company:");

        jLabel58.setText("Knóos");

        javax.swing.GroupLayout ContactProfileLayout = new javax.swing.GroupLayout(ContactProfile);
        ContactProfile.setLayout(ContactProfileLayout);
        ContactProfileLayout.setHorizontalGroup(
            ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 706, Short.MAX_VALUE)
            .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(ContactProfileLayout.createSequentialGroup()
                    .addGap(0, 247, Short.MAX_VALUE)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel43)
                            .addGap(36, 36, 36)
                            .addComponent(jLabel45))
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel47)
                            .addGap(7, 7, 7)
                            .addComponent(jLabel49))
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel51)
                            .addGap(37, 37, 37)
                            .addComponent(jLabel52))
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel53)
                            .addGap(5, 5, 5)
                            .addComponent(jLabel54))
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel55)
                            .addGap(22, 22, 22)
                            .addComponent(jLabel56))
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addComponent(jLabel57)
                            .addGap(13, 13, 13)
                            .addComponent(jLabel58)))
                    .addGap(0, 248, Short.MAX_VALUE)))
        );
        ContactProfileLayout.setVerticalGroup(
            ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 432, Short.MAX_VALUE)
            .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(ContactProfileLayout.createSequentialGroup()
                    .addGap(0, 144, Short.MAX_VALUE)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel43)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel45)))
                    .addGap(6, 6, 6)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel47)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel49)))
                    .addGap(6, 6, 6)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel51)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel52)))
                    .addGap(6, 6, 6)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel53)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel54)))
                    .addGap(6, 6, 6)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel55)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel56)))
                    .addGap(6, 6, 6)
                    .addGroup(ContactProfileLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel57)
                        .addGroup(ContactProfileLayout.createSequentialGroup()
                            .addGap(2, 2, 2)
                            .addComponent(jLabel58)))
                    .addGap(0, 144, Short.MAX_VALUE)))
        );

        jTabbedPane3.addTab("Contact profile", ContactProfile);

        javax.swing.GroupLayout ProfilePanelLayout = new javax.swing.GroupLayout(ProfilePanel);
        ProfilePanel.setLayout(ProfilePanelLayout);
        ProfilePanelLayout.setHorizontalGroup(
            ProfilePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 718, Short.MAX_VALUE)
            .addGroup(ProfilePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(ProfilePanelLayout.createSequentialGroup()
                    .addComponent(jTabbedPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 718, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        ProfilePanelLayout.setVerticalGroup(
            ProfilePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 475, Short.MAX_VALUE)
            .addGroup(ProfilePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jTabbedPane3))
        );

        MainPageCP.add(ProfilePanel, "ProfilePanel");

        TransferRequestList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        TransferRequestList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                TransferRequestListValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(TransferRequestList);

        jLabel21.setText("Transfer Request");

        jLabel22.setText("Request user");

        TransferAcceptButton.setText("Accept");
        TransferAcceptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TransferAcceptButtonActionPerformed(evt);
            }
        });

        TransferRefuseButton.setText("Refuse");
        TransferRefuseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TransferRefuseButtonActionPerformed(evt);
            }
        });

        jLabel7.setText("Downloaded");

        DownloadingList.setPreferredSize(new java.awt.Dimension(200, 100));
        jScrollPane2.setViewportView(DownloadingList);

        jLabel8.setText("Uploaded");

        jScrollPane4.setViewportView(UploadingList);

        RequestUserList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                RequestUserListValueChanged(evt);
            }
        });
        jScrollPane5.setViewportView(RequestUserList);

        javax.swing.GroupLayout TransferPanelLayout = new javax.swing.GroupLayout(TransferPanel);
        TransferPanel.setLayout(TransferPanelLayout);
        TransferPanelLayout.setHorizontalGroup(
            TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TransferPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addGroup(TransferPanelLayout.createSequentialGroup()
                        .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 315, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel21))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel22)
                            .addGroup(TransferPanelLayout.createSequentialGroup()
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(TransferRefuseButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(TransferAcceptButton, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)))))
                    .addComponent(jScrollPane4)
                    .addComponent(jScrollPane2))
                .addGap(183, 183, 183))
        );
        TransferPanelLayout.setVerticalGroup(
            TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TransferPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(TransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(TransferPanelLayout.createSequentialGroup()
                        .addComponent(TransferAcceptButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TransferRefuseButton)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                    .addComponent(jScrollPane5))
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        MainPageCP.add(TransferPanel, "TransferPanel");

        ContactsPanel.setPreferredSize(new java.awt.Dimension(665, 475));
        java.awt.GridBagLayout ContactsPanelLayout = new java.awt.GridBagLayout();
        ContactsPanelLayout.columnWidths = new int[] {0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0};
        ContactsPanelLayout.rowHeights = new int[] {0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0};
        ContactsPanel.setLayout(ContactsPanelLayout);

        jLabel4.setText("Connected contacts");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 11;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
        ContactsPanel.add(jLabel4, gridBagConstraints);

        ContactsList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane12.setViewportView(ContactsList);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 13;
        gridBagConstraints.gridheight = 31;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 0.3;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        ContactsPanel.add(jScrollPane12, gridBagConstraints);

        jButton10.setText("View profile");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 38;
        gridBagConstraints.gridwidth = 13;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        ContactsPanel.add(jButton10, gridBagConstraints);

        jLabel41.setText("Chat");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
        ContactsPanel.add(jLabel41, gridBagConstraints);

        ChatSendButton.setText("Send");
        ChatSendButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChatSendButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 56;
        gridBagConstraints.gridy = 40;
        ContactsPanel.add(ChatSendButton, gridBagConstraints);

        ChatBoard.setColumns(20);
        ChatBoard.setRows(5);
        jScrollPane13.setViewportView(ChatBoard);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 41;
        gridBagConstraints.gridheight = 31;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        ContactsPanel.add(jScrollPane13, gridBagConstraints);

        jScrollPane14.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        TextToSend.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                TextToSendKeyPressed(evt);
            }
        });
        jScrollPane14.setViewportView(TextToSend);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 16;
        gridBagConstraints.gridy = 36;
        gridBagConstraints.gridwidth = 39;
        gridBagConstraints.gridheight = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        ContactsPanel.add(jScrollPane14, gridBagConstraints);

        MainPageCP.add(ContactsPanel, "ContactsPanel");

        MainPageSB.setMinimumSize(new java.awt.Dimension(0, 0));
        MainPageSB.setRequestFocusEnabled(false);
        MainPageSB.setLayout(new java.awt.GridLayout(8, 1));

        SearchButtonSB.setText("Search");
        SearchButtonSB.setAlignmentY(0.0F);
        SearchButtonSB.setPreferredSize(new java.awt.Dimension(100, 20));
        SearchButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(SearchButtonSB);

        ImageButtonSB.setText("Image");
        ImageButtonSB.setPreferredSize(new java.awt.Dimension(100, 20));
        ImageButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ImageButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(ImageButtonSB);

        ContactsButtonSB.setText("Contacts");
        ContactsButtonSB.setPreferredSize(new java.awt.Dimension(100, 20));
        ContactsButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ContactsButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(ContactsButtonSB);

        TransferButtonSB.setText("Transfer");
        TransferButtonSB.setAlignmentY(0.0F);
        TransferButtonSB.setPreferredSize(new java.awt.Dimension(100, 20));
        TransferButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TransferButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(TransferButtonSB);

        ProfileButtonSB.setText("Profile");
        ProfileButtonSB.setPreferredSize(new java.awt.Dimension(100, 20));
        ProfileButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ProfileButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(ProfileButtonSB);

        LogoutButtonSB.setText("Logout");
        LogoutButtonSB.setPreferredSize(new java.awt.Dimension(100, 29));
        LogoutButtonSB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LogoutButtonSBActionPerformed(evt);
            }
        });
        MainPageSB.add(LogoutButtonSB);

        jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);

        javax.swing.GroupLayout MainPagePanelLayout = new javax.swing.GroupLayout(MainPagePanel);
        MainPagePanel.setLayout(MainPagePanelLayout);
        MainPagePanelLayout.setHorizontalGroup(
            MainPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPagePanelLayout.createSequentialGroup()
                .addComponent(MainPageCP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(MainPageSB, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(MainPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MainPagePanelLayout.createSequentialGroup()
                    .addContainerGap(716, Short.MAX_VALUE)
                    .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(93, 93, 93)))
        );
        MainPagePanelLayout.setVerticalGroup(
            MainPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPagePanelLayout.createSequentialGroup()
                .addGroup(MainPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(MainPageCP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(MainPageSB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(41, Short.MAX_VALUE))
            .addGroup(MainPagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(MainPagePanelLayout.createSequentialGroup()
                    .addComponent(jSeparator5, javax.swing.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
                    .addContainerGap()))
        );

        MainPanel.add(MainPagePanel, "MainPagePanel");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(MainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 516, Short.MAX_VALUE)
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void UserFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UserFieldActionPerformed
    }//GEN-LAST:event_UserFieldActionPerformed

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
       
        String user = UserField.getText();
        String password = PasswordField.getText();
        try {
            IM.login(user,password,RESOURCE);
        } catch (NullPointerException ex) {
            if(logger.isDebugEnabled()){
                logger.error(ex.getMessage());
            }
            JOptionPane.showMessageDialog(this,"Password or username field is empty","P2PPicture Error",JOptionPane.WARNING_MESSAGE);
        } catch (XMPPException ex) {
            if(logger.isDebugEnabled()){
                logger.error(ex.getMessage());
            }
            JOptionPane.showMessageDialog(this,"Wrong password. Try again","P2PPicture Error",JOptionPane.WARNING_MESSAGE);
            PasswordField.setText("");
        }
        if(IM.getConnection().isAuthenticated()){
            CardLayout cl = (CardLayout)(MainPanel.getLayout());
            cl.show(MainPanel,"MainPagePanel");
            ContactsList.setListData(IM.getConnectedUsers());
            IM.initializeManager();
            
            filter = new AndFilter(new PacketTypeFilter(Message.class),new NotFilter(new FromContainsFilter(IM.getConnection().getUser())));
            IM.getConnection().createPacketCollector(filter);
            IM.getConnection().addPacketListener(this, filter);
            
            InitializeTransfers();
            InitializeResults();
            InitializeAlbum();
            InitializeCounters();
        }
        else{
            JOptionPane.showMessageDialog(this,"Connection error","P2PPicture Error",JOptionPane.WARNING_MESSAGE);
            CardLayout cl = (CardLayout)(MainPanel.getLayout());
            cl.show(MainPanel,"LoginPanel");
        }
    }//GEN-LAST:event_LoginButtonActionPerformed

    private void SearchButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonSBActionPerformed
       
        CardLayout cl = (CardLayout)(MainPageCP.getLayout());
        cl.show(MainPageCP,"SearchPanel");
    }//GEN-LAST:event_SearchButtonSBActionPerformed

    private void ContactsButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ContactsButtonSBActionPerformed
        CardLayout cl = (CardLayout)(MainPageCP.getLayout());
        cl.show(MainPageCP,"ContactsPanel");
    }//GEN-LAST:event_ContactsButtonSBActionPerformed

    private void LogoutButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LogoutButtonSBActionPerformed
        IM.logout();
        
        CardLayout cl = (CardLayout)(MainPanel.getLayout());
        cl.show(MainPanel,"LoginPanel");
        ChatBoard.setText("");
    }//GEN-LAST:event_LogoutButtonSBActionPerformed

    private void ImageButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImageButtonSBActionPerformed
       
        CardLayout cl = (CardLayout)(MainPageCP.getLayout());
        cl.show(MainPageCP,"ImagePanel");
    }//GEN-LAST:event_ImageButtonSBActionPerformed

    private void TransferButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TransferButtonSBActionPerformed
        CardLayout cl = (CardLayout)(MainPageCP.getLayout());
        cl.show(MainPageCP,"TransferPanel");
    }//GEN-LAST:event_TransferButtonSBActionPerformed

    private void SubmitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SubmitButtonActionPerformed
        // TODO Register a new user to the system
        CardLayout cl = (CardLayout)(MainPanel.getLayout());
        cl.show(MainPanel,"LoginPanel");
    }//GEN-LAST:event_SubmitButtonActionPerformed

    private void RegisterLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RegisterLabelMouseClicked
       
        CardLayout cl = (CardLayout)(MainPanel.getLayout());
        cl.show(MainPanel,"RegisterPanel");
    }//GEN-LAST:event_RegisterLabelMouseClicked

    private void ProfileButtonSBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ProfileButtonSBActionPerformed
       
        CardLayout cl = (CardLayout)(MainPageCP.getLayout());
        cl.show(MainPageCP,"ProfilePanel");
    }//GEN-LAST:event_ProfileButtonSBActionPerformed

    private void ContactEmailTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ContactEmailTFActionPerformed
       
    }//GEN-LAST:event_ContactEmailTFActionPerformed

    private void SaveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveButtonActionPerformed
        JFileChooser f = fSaver();
        if(f.getSelectedFile().getName().endsWith(".jpg") || f.getSelectedFile().getName().endsWith(".jpeg")){
           ed.saveJPEGQuality(f.getSelectedFile().getAbsolutePath(),(float)JPEGSlider.getValue()/100);
           if(logger.isDebugEnabled()){
                logger.info(JPEGSlider.getValue());
           }
        }          
        else{   
            String ext = null;
            String s = f.getSelectedFile().getName();
            int i = s.lastIndexOf('.'); 
            if (i > 0 &&  i < s.length() - 1) {
                ext = s.substring(i+1).toLowerCase();
            }
            ed.saveImage(f.getSelectedFile().getAbsolutePath(), ext);
        }       
    }//GEN-LAST:event_SaveButtonActionPerformed

    private void UploadBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UploadBrowseButtonActionPerformed
        JFileChooser f = fChooser();               
        String filename = f.getSelectedFile().getAbsolutePath();
        SelectedImageTF.setText(filename);
        
        PlanarImage im = JAI.create("fileload",filename);
        
        setThumbnail(UploadImPanel,im);      
                               
        im = null; System.gc();
        
    }//GEN-LAST:event_UploadBrowseButtonActionPerformed

    private void TagsTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TagsTFActionPerformed
       
    }//GEN-LAST:event_TagsTFActionPerformed
    private void SlideshowButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SlideshowButtonActionPerformed
        try {
            AlbumThumbPanel.removeAll();
                AlbumThumbPanel.updateUI();
                AlbumThumbPanel.repaint();
            new VisualizerImpl(SlideShowFiles, "out.html");
        } catch (URISyntaxException ex) {
            logger.error(ex.getMessage());
        } catch (IOException ex) {
            logger.error(ex.getMessage());
        }
    }//GEN-LAST:event_SlideshowButtonActionPerformed

    private void AlbumListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_AlbumListValueChanged
            //Slideshow
            SlideShowFiles = new ArrayList<String>();
            JList list = (JList) evt.getSource();
            int[] i = list.getSelectedIndices();
            String slide="";
            for(int j=0;j<i.length;j++){               
                String file = (String)list.getModel().getElementAt(i[j]);            
                
                // adapt to windows
                if (File.separator.equals("\\")) {
                    slide = file.replace("\\", "\\"+"\\");
                }
                SlideShowFiles.add(slide);
                
            }
            //Thumbnail
            
            if(list.getSelectedIndex() != -1){
                String filePath = (String) list.getModel().getElementAt(list.getSelectedIndex());
                PlanarImage im = JAI.create("fileload",filePath);
                             
                setThumbnail(AlbumThumbPanel,im);      
                               
                im = null; System.gc();
            }
    }//GEN-LAST:event_AlbumListValueChanged

    private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonActionPerformed
        // Clean previous queries
        InitializeResults();        
        
        Scanner tokenize = new Scanner(SearchField.getText());
        ArrayList<String> tokens = new ArrayList<String>();
        while (tokenize.hasNext()) {
            tokens.add(tokenize.next());
        }
        final String typeOfSearch;
        if(AdvancedSearchButton.isSelected()){
            typeOfSearch = (String)jComboBox1.getSelectedItem();
        }
        else if(NewsRB.isSelected()){
            typeOfSearch = "query.searchNewsParagraph";
        }
        else{
            typeOfSearch = "query.freeSearchPicture";
        }
        try {
            IM.search(IM.getConnectedUsers(), typeOfSearch, tokens);
        } catch (XMPPException ex) {
            JOptionPane.showMessageDialog(this,"Connection error: "+ex.getMessage(),"P2PPicture Error",JOptionPane.WARNING_MESSAGE);
        } catch (NullPointerException ex) {
        }
    }//GEN-LAST:event_SearchButtonActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
       
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void ChatSendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChatSendButtonActionPerformed
       
        int selectedIndex = ContactsList.getSelectedIndex();
        String to = (String)ContactsList.getModel().getElementAt(selectedIndex);
        String body = TextToSend.getText();
        if(IM.getConnection().isAuthenticated()){
            IM.sendChatMessage(body,to);            
            ChatBoard.append(IM.getConnection().getUser()+"-->"+to+": "+ body + "\n");
        }
        TextToSend.setText("");
    }//GEN-LAST:event_ChatSendButtonActionPerformed

    private void TextToSendKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TextToSendKeyPressed
        int key = evt.getKeyCode();
        if (key == KeyEvent.VK_ENTER) {
            evt.consume();
            this.ChatSendButtonActionPerformed(null);
        }
    }//GEN-LAST:event_TextToSendKeyPressed

    private void PasswordFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_PasswordFieldKeyPressed

    }//GEN-LAST:event_PasswordFieldKeyPressed

    private void SearchFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SearchFieldKeyPressed

    }//GEN-LAST:event_SearchFieldKeyPressed

    private void UploadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UploadButtonActionPerformed
        File directory = new File("images");
        boolean exists = directory.exists();
        if(!exists){
            new File("images").mkdir();
            if(logger.isDebugEnabled()){
                logger.info("Creating a folder");
            }
        }
        File source = new File(SelectedImageTF.getText());
        try {
            FileUtils.copyFileToDirectory(source, directory);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this,"Error copying the image file in the album","P2PPicture Error",JOptionPane.WARNING_MESSAGE);
        }
        
        //Update album list
        DefaultListModel model = (DefaultListModel)AlbumList.getModel();
        model.add(model.size(),directory.getAbsolutePath()+System.getProperty("file.separator")+source.getName());

        AlbumThumbPanel.removeAll();
        AlbumThumbPanel.updateUI();
        AlbumThumbPanel.repaint();
        
        //insert picture in the database
        final String action = "addPicture";
        DBActionImpl dba = new DBActionImpl(action);
        String[] picture;
       
        // Collecting the data from the UI
        //id
        Random generator = new Random();
        int r = generator.nextInt();
        //format
        int mid= source.getName().lastIndexOf(".");
        String ext=source.getName().substring(mid+1,source.getName().length());
        // data        
        Date date = new Date();
        //resolution
        PlanarImage img = JAI.create("fileload",directory.getAbsolutePath()+System.getProperty("file.separator")+source.getName()); 
        int[] res ={img.getWidth(),img.getHeight()};
        img = null; System.gc();
        //size
        File f = new File(directory.getAbsolutePath()+System.getProperty("file.separator")+source.getName());
        long size = f.length();
        //tags
        String[] pieces = TagsTF.getText().split(" ");
        for(int i=pieces.length - 1;i>=0;i--){
            pieces[i] = pieces[i].trim();
        }
        List<String> keywords = Arrays.asList(pieces);
        //adding to a ImageImpl Object
        ImageImpl im = new ImageImpl(r, directory.getAbsolutePath()+System.getProperty("file.separator")+source.getName(), uploadDescription.getText(),ext , date, res, size, "Bytes", keywords, (String)OntologyCB.getSelectedItem());
        
        picture = parsePicture(im);
        
        dba.setParameters(picture);

        DBManagerImpl manager = DBManagerImpl.getInstance();
        DBActionResultImpl dbari = manager.execute(dba);
        
        
    }//GEN-LAST:event_UploadButtonActionPerformed

    private void EditImageBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditImageBrowseButtonActionPerformed
        JFileChooser f = fChooser();
        String filename = f.getSelectedFile().getAbsolutePath();
        ed.setFilename(filename);
        EditImageLabel.setText(f.getSelectedFile().getName());
        ed.loadImage(filename);
        refreshEditorPanel(ed.getOutput());
    }//GEN-LAST:event_EditImageBrowseButtonActionPerformed

    private void ResizeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResizeButtonActionPerformed
        int n = Integer.parseInt(WidthTF.getText());
        int m = Integer.parseInt(HeightTF.getText());
        if(null != ed.getInput()){
            ed.changeSize((float)n/100, (float)m/100);
            refreshEditorPanel(ed.getOutput());
        }
        else{
            JOptionPane.showMessageDialog(this, "An image must be loaded. Press browse button and choose one");
        }
    }//GEN-LAST:event_ResizeButtonActionPerformed

    private void CancelButtonJPEGQualityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelButtonJPEGQualityActionPerformed
       
    }//GEN-LAST:event_CancelButtonJPEGQualityActionPerformed

    private void AcceptButtonJPEGQualityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AcceptButtonJPEGQualityActionPerformed
       
    }//GEN-LAST:event_AcceptButtonJPEGQualityActionPerformed

    private void DiscardChangeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DiscardChangeButtonActionPerformed
        if(null != ed.getInput()){            
            resetSliders();
            WidthTF.setText("100"); HeightTF.setText("100");
            ed.setOutput(ed.getInput());
            refreshEditorPanel(ed.getInput());            
        }
    }//GEN-LAST:event_DiscardChangeButtonActionPerformed

    private void RotateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RotateButtonActionPerformed
        if(null != ed.getInput()){
            ed.rotating(Float.valueOf(RotateTF.getText()));
            refreshEditorPanel(ed.getOutput());
        }
    }//GEN-LAST:event_RotateButtonActionPerformed

    private void TransferAcceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TransferAcceptButtonActionPerformed
    
        String file = (String)TransferRequestList.getSelectedValue();        
        String contact = (String)RequestUserList.getSelectedValue();
        
        if(logger.isDebugEnabled()){
            logger.info("file to transfer: "+file+" to "+contact);
        }
        if(null != file && null != contact){
            if(logger.isDebugEnabled()){
                logger.info("file to transfer: "+file+" to "+contact);
            }
            IM.getListener().getTransfer().sendFile(contact,file);
        }
        // Remove petition
        int idx = TransferRequestList.getSelectedIndex();
        DefaultListModel model = (DefaultListModel) TransferRequestList.getModel();
        model.removeElementAt(idx);
        model = (DefaultListModel)RequestUserList.getModel();
        model.removeElementAt(idx);
        // Adding the downloaded item to the list
        DefaultListModel dModel = (DefaultListModel) DownloadingList.getModel();
        String txt="";
        txt=file+" to "+contact;
        logger.info("to the dwn list"+txt);
        dModel.add(dModel.size(),txt);
    }//GEN-LAST:event_TransferAcceptButtonActionPerformed

    private void DeleteImageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteImageButtonActionPerformed
        
        AlbumThumbPanel.removeAll();
        AlbumThumbPanel.updateUI();
        AlbumThumbPanel.repaint();
        
        int item = AlbumList.getSelectedIndex();
        if(logger.isDebugEnabled()){
            logger.info("index "+item);
        }
        if(item != -1){
            String filePath =((String)(AlbumList.getModel().getElementAt(item)));
            
            File file = new File(filePath);
            if(logger.isDebugEnabled()){
                logger.info("file to delete: "+file.getAbsolutePath());
            }
            boolean deleted = file.delete();
            if(deleted){
                if(logger.isDebugEnabled()){
                    logger.info("successfully deleted");
                }
            }
            DefaultListModel model = (DefaultListModel)AlbumList.getModel();
            model.remove(item);           
        }
    }//GEN-LAST:event_DeleteImageButtonActionPerformed

    private void SharpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SharpButtonActionPerformed
        if(null != ed.getInput()){
            ed.sharpening();
        }
        refreshEditorPanel(ed.getOutput());
    }//GEN-LAST:event_SharpButtonActionPerformed

    private void BlurSliderMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_BlurSliderMouseReleased
        int factor = BlurSlider.getValue();
        if(null != ed.getInput()){
            ed.blurring((2*factor)+1);
            refreshEditorPanel(ed.getOutput());
        }
    }//GEN-LAST:event_BlurSliderMouseReleased

    private void AdaptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdaptButtonActionPerformed
        refreshEditorPanel(adaptToParent(jScrollPane3, ed.getOutput()));
    }//GEN-LAST:event_AdaptButtonActionPerformed

    private void ContrastSliderMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ContrastSliderMouseReleased
        int factor = ContrastSlider.getValue();
        if(null != ed.getInput()){
            ed.changeContrast((float)(1+(factor*0.125)));
            refreshEditorPanel(ed.getOutput());
        }
    }//GEN-LAST:event_ContrastSliderMouseReleased

    private void DownloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DownloadButtonActionPerformed
        try {
            String resource = (String)ResultsContentList.getSelectedValue();
            if(logger.isDebugEnabled()){
                logger.info("content to download: "+resource);
            }
            String user = Owner.getText();
            // Send UC
            IM.requestContent(resource, user);
        } catch (XMPPException ex) {
            if(logger.isDebugEnabled()){
                logger.error(ex.getMessage());
            }
        }
    }//GEN-LAST:event_DownloadButtonActionPerformed

    private void ResultsContentListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_ResultsContentListValueChanged
        //Thumbnail
        List<Packet> packets = IM.getInbox();
        String selected = (String)ResultsContentList.getSelectedValue();
        if(logger.isDebugEnabled()){
            logger.info("Selected: "+selected);
        }
        Iterator itr = packets.iterator();
        SearchResultImpl SR;
        Packet packet;
        String from;
        List<ContentImpl> contents;
        while(itr.hasNext()){
            packet = (Packet)itr.next();
            SR = (SearchResultImpl)(packet.getProperty(SEARCHRESULT));
            from = packet.getFrom();
            contents = SR.getContents();
            Iterator ir = contents.iterator();
            DescriptionContentImpl dc;
            ThumbnailImpl th;
            ContentImpl Content;
            while(ir.hasNext()){ 
                Content = (ContentImpl)ir.next();
                dc = Content.getDescriptionContent();
                th = Content.getThumbnail();
                if(dc.getURL().equals(selected)){
                    // User
                    Owner.setText(from);
                    // Thumbnail
                    ImageIcon img = th.getImageIcon();
                    BufferedImage bi = new BufferedImage(img.getIconWidth(),img.getIconHeight(),BufferedImage.TYPE_INT_RGB);
                    bi.getGraphics().drawImage(img.getImage(), 0, 0, null);
                    PlanarImage im = PlanarImage.wrapRenderedImage(bi);
                    
                    setThumbnail(ResultThumbPanel,im);      
                               
                    im = null; System.gc();
                    // Description
                    Iterator dcItr = dc.getDescription().iterator();
                    String out ="";
                    while(dcItr.hasNext()){
                        out = out + " " + ((String)dcItr.next());
                    }
                    ResultTP.setText(out);
                }
            }
        }
        
    }//GEN-LAST:event_ResultsContentListValueChanged

    private void SearchProfileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchProfileButtonActionPerformed
        
    }//GEN-LAST:event_SearchProfileButtonActionPerformed

    private void TransferRefuseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TransferRefuseButtonActionPerformed
        // Remove file
        DefaultListModel model = (DefaultListModel)TransferRequestList.getModel();
        int idx = TransferRequestList.getSelectedIndex();
        model.removeElementAt(idx);
        // Remove user
        model = (DefaultListModel)RequestUserList.getModel();
        model.removeElementAt(idx);  
    }//GEN-LAST:event_TransferRefuseButtonActionPerformed

    private void TransferRequestListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_TransferRequestListValueChanged
        int idx = TransferRequestList.getSelectedIndex();
        RequestUserList.setSelectedIndex(idx);
    }//GEN-LAST:event_TransferRequestListValueChanged

    private void RequestUserListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_RequestUserListValueChanged
        int idx = RequestUserList.getSelectedIndex();
        TransferRequestList.setSelectedIndex(idx);
    }//GEN-LAST:event_RequestUserListValueChanged

    private void NewsRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewsRBActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NewsRBActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            if(logger.isDebugEnabled())
            logger.error(ex.getMessage());
        } catch (InstantiationException ex) {
            if(logger.isDebugEnabled())
            logger.error(ex.getMessage());
        } catch (IllegalAccessException ex) {
            if(logger.isDebugEnabled())
            logger.error(ex.getMessage());
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            if(logger.isDebugEnabled())
            logger.error(ex.getMessage());
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new P2PPictureClient().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AcceptButtonJPEGQuality;
    private javax.swing.JLabel AccessLabel;
    private javax.swing.JButton AdaptButton;
    private javax.swing.JButton AddContact;
    private javax.swing.JRadioButton AdvancedSearchButton;
    private javax.swing.JList AlbumList;
    private javax.swing.JPanel AlbumTAB;
    private javax.swing.JPanel AlbumThumbPanel;
    private javax.swing.JSlider BlurSlider;
    private javax.swing.JButton CancelButtonJPEGQuality;
    private javax.swing.JTextArea ChatBoard;
    private javax.swing.JButton ChatSendButton;
    private javax.swing.JTextField ContactEmailTF;
    private javax.swing.JTextField ContactNameTF;
    private javax.swing.JPanel ContactProfile;
    private javax.swing.JButton ContactsButtonSB;
    private javax.swing.JList ContactsList;
    private javax.swing.JPanel ContactsPanel;
    private javax.swing.JSlider ContrastSlider;
    private javax.swing.JButton DeleteImageButton;
    private javax.swing.JButton DiscardChangeButton;
    private javax.swing.JButton DownloadButton;
    private javax.swing.JList DownloadingList;
    private javax.swing.JButton EditImageBrowseButton;
    private javax.swing.JLabel EditImageLabel;
    private javax.swing.JPanel EditImageToolPanel;
    private javax.swing.JPanel EditMyProfile;
    private javax.swing.JPanel EditTAB;
    private javax.swing.JTextField HeightTF;
    private javax.swing.JButton ImageButtonSB;
    private javax.swing.JPanel ImageP;
    private javax.swing.JPanel ImagePanel;
    private javax.swing.JTabbedPane ImageTabbedPanel;
    private javax.swing.JDialog JPEGDialog;
    private javax.swing.JSlider JPEGSlider;
    private javax.swing.JButton LoginButton;
    private javax.swing.JPanel LoginPanel;
    private javax.swing.JButton LogoutButtonSB;
    private javax.swing.JPanel MainPageCP;
    private javax.swing.JPanel MainPagePanel;
    private javax.swing.JPanel MainPageSB;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JPanel MidPanel;
    private javax.swing.JPanel MyProfile;
    private javax.swing.JRadioButton NewsRB;
    private javax.swing.JRadioButton NormalSearchButton;
    private javax.swing.JComboBox OntologyCB;
    private javax.swing.JLabel OntologyLB;
    private javax.swing.JLabel Owner;
    private javax.swing.JPasswordField PasswordField;
    private javax.swing.JLabel PasswordLabel;
    private javax.swing.JButton ProfileButtonSB;
    private javax.swing.JPanel ProfilePanel;
    private javax.swing.JLabel Register;
    private javax.swing.JLabel RegisterLabel;
    private javax.swing.JPanel RegisterPanel;
    private javax.swing.JList RequestUserList;
    private javax.swing.JButton ResizeButton;
    private javax.swing.JTextPane ResultTP;
    private javax.swing.JPanel ResultThumbPanel;
    private javax.swing.JList ResultsContentList;
    private javax.swing.JScrollPane ResultsContentPanel;
    private javax.swing.JLabel ResultsLabel;
    private javax.swing.JButton RotateButton;
    private javax.swing.JTextField RotateTF;
    private javax.swing.JButton SaveButton;
    private javax.swing.ButtonGroup SearchBG;
    private javax.swing.JButton SearchButton;
    private javax.swing.JButton SearchButtonSB;
    private javax.swing.JButton SearchContactButton;
    private javax.swing.JPanel SearchContacts;
    private javax.swing.JPanel SearchContent;
    private javax.swing.JTextField SearchField;
    private javax.swing.JLabel SearchLB;
    private javax.swing.JPanel SearchPanel;
    private javax.swing.JButton SearchProfileButton;
    private javax.swing.JLabel SelectedImageLB;
    private javax.swing.JTextField SelectedImageTF;
    private javax.swing.JButton SharpButton;
    private javax.swing.JSlider SliderJPEGFactor;
    private javax.swing.JButton SlideshowButton;
    private javax.swing.JButton SubmitButton;
    private javax.swing.JLabel TagsLB;
    private javax.swing.JTextField TagsTF;
    private javax.swing.JEditorPane TextToSend;
    private javax.swing.JButton TransferAcceptButton;
    private javax.swing.JButton TransferButtonSB;
    private javax.swing.JPanel TransferPanel;
    private javax.swing.JButton TransferRefuseButton;
    private javax.swing.JList TransferRequestList;
    private javax.swing.JButton UploadBrowseButton;
    private javax.swing.JButton UploadButton;
    private javax.swing.JPanel UploadImPanel;
    private javax.swing.JPanel UploadTAB;
    private javax.swing.JList UploadingList;
    private javax.swing.JTextField UserField;
    private javax.swing.JList UserFoundList;
    private javax.swing.JScrollPane UserFoundListPane;
    private javax.swing.JLabel UserLabel;
    private javax.swing.JTextField WidthTF;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JLabel jLabel54;
    private javax.swing.JLabel jLabel55;
    private javax.swing.JLabel jLabel56;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JTextField uploadDescription;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    public void processPacket(Packet packet) {
        if(packet instanceof Message && null == packet.getProperty("UserContent") && null == packet.getProperty("SearchProfile") && null == packet.getProperty("SearchResult")){
            logger.info("A chat message has arrived");
            Message msg = (Message) packet;
            String body = msg.getBody();
            ChatBoard.append(msg.getFrom()+": "+body+"\n");
        }
    }
    
    public JFileChooser fChooser(){        
        FileNameExtensionFilter filter;
        JFileChooser f = new JFileChooser();  
        filter = new FileNameExtensionFilter("bmp files","bmp");
        f.setFileFilter(filter);
        filter = new FileNameExtensionFilter("jpeg files", "jpg","jpeg");
        f.setFileFilter(filter);
        filter = new FileNameExtensionFilter("png files","png");
        f.setFileFilter(filter); 
        filter = new FileNameExtensionFilter("P2PPicture valid formats", "jpg","png", "bmp", "jpeg");
        f.setFileFilter(filter);
        int returnVal = f.showOpenDialog(new JFrame());
        return (f);
    }
    
    public JFileChooser fSaver(){
        FileNameExtensionFilter filter;
        JFileChooser f = new JFileChooser();    
        filter = new FileNameExtensionFilter("bmp files","bmp");
        f.setFileFilter(filter);
        filter = new FileNameExtensionFilter("jpeg files", "jpg","jpeg");
        f.setFileFilter(filter);
        filter = new FileNameExtensionFilter("png files","png");
        f.setFileFilter(filter);       
        filter = new FileNameExtensionFilter("P2PPicture valid formats", "jpg","png", "bmp", "jpeg");
        f.setFileFilter(filter);
        int returnVal = f.showSaveDialog(new JFrame());
        return f;
    }
    
    public void refreshEditorPanel(PlanarImage im){
        DisplayJAI dj = new DisplayJAI(im);
        JPanel ip = new JPanel();
        ip.add(dj);
        //ImageP.removeAll();
        ImageP.removeAll();
        ImageP.add(ip);
        ImageP.updateUI();
        ImageP.repaint();
    }
    
    public void resetSliders(){
        ContrastSlider.setValue(0);
        BlurSlider.setValue(0);
        JPEGSlider.setValue(0);
    }
    
    public PlanarImage adaptToParent(JComponent parent, PlanarImage im){       
        int panelWidth = parent.getWidth();
        int panelHeight = parent.getHeight();
        double propWidth = (double)im.getWidth()/(double)panelWidth;
        double propHeight = (double)im.getHeight()/(double)panelHeight;
        
        double max = propWidth;
        if(propHeight>max){
            max=propHeight;
        }
        ParameterBlock pb = new ParameterBlock();
            pb.addSource(im);                   // The source image
            pb.add((float)(1/max));                        // The xScale
            pb.add((float)(1/max));                        // The yScale
            pb.add(0.0F);                       // The x translation
            pb.add(0.0F);                       // The y translation
            pb.add(new InterpolationNearest()); // The interpolation
        // Create the scale operation
        PlanarImage imScaled = JAI.create("scale", pb, null); 
        
        return imScaled;        
    }

    public void update(Observable o, Object arg) {
        if(o == IM){
            if(nInbox != IM.getInbox().size()) {
                // If the SR inbox changes, the SR is proccessed to be integrated to the interface
                if(logger.isDebugEnabled()){
                    logger.info("SR received");
                }
                List<Packet> inbox = IM.getInbox();
                Iterator itr = inbox.iterator();
                Packet packet;
                SearchResultImpl SR;
                while(itr.hasNext()){
                    packet = (Packet)itr.next();
                    SR = (SearchResultImpl) packet.getProperty(SEARCHRESULT);
                    processSRContents(SR);
                }
                nInbox = IM.getInbox().size();
            }
            HashMap<String,String> req = (HashMap<String,String>) ((InstantMessageImpl)o).getRequests();
            if(nReq != req.size()){
                // If a file transfer request arrives, this request is integrated to the UI
                
                processRequests(req);
                nReq = req.size();
            }
            if(nUsers != IM.getConnectedUsers().size()){
                // If a contact changes to avalaible/unavaible, the contact list changes
                ContactsList.setListData(IM.getConnectedUsers());
                nUsers = IM.getConnectedUsers().size();
            }
        }
    }

    private void processSRContents(SearchResultImpl SR) {
        //Adds the new results in the results area
        List<ContentImpl> contents = SR.getContents();
        Iterator itr = contents.iterator();
        while(itr.hasNext()){
            // Put the URL in the list
            DescriptionContentImpl dc = ((ContentImpl)itr.next()).getDescriptionContent();
            DefaultListModel model = (DefaultListModel)ResultsContentList.getModel();
            model.add(model.size(),dc.getURL());            
        }
    }
    
    public void processRequests(HashMap requests){
        if(logger.isDebugEnabled()){
            logger.debug("Enters in processRequests");
        }
        DefaultListModel model = (DefaultListModel)TransferRequestList.getModel();
        DefaultListModel modelReceiver = (DefaultListModel)RequestUserList.getModel();
        Set set = requests.entrySet();
        Iterator i = set.iterator();
        String content, receiver;
        if(logger.isDebugEnabled()){
            logger.debug(requests.size());
        }
        while(i.hasNext()){
            Map.Entry me = (Map.Entry)i.next();
            // Map<content->key,receiver->value>
            content = (String) me.getKey();
            receiver = (String) me.getValue();
            model.add(model.size(),content);
            modelReceiver.add(modelReceiver.size(),receiver);
        }
        IM.getRequests().clear();
    }
    
    public void InitializeResults(){
        DefaultListModel listModel = new DefaultListModel();
        ResultsContentList.setModel(listModel);
        ResultTP.setText("");
        Owner.setText("");
        ResultThumbPanel.removeAll();
        ResultThumbPanel.updateUI();
        ResultThumbPanel.repaint();
    }
    
    public void InitializeTransfers(){
        DefaultListModel listModel = new DefaultListModel();
        TransferRequestList.setModel(listModel);
        DefaultListModel listModelReceiver = new DefaultListModel();
        RequestUserList.setModel(listModelReceiver);
        DefaultListModel dlistModel = new DefaultListModel();
        DownloadingList.setModel(dlistModel);
        DefaultListModel ulistModel = new DefaultListModel();
        UploadingList.setModel(ulistModel);
        
        
    }
    
    public void InitializeAlbum(){
        DefaultListModel listModel = new DefaultListModel();
        String dir = "images";
        File folder = new File(dir);
        if(false == folder.exists()){
            new File("images").mkdir();
        }
        
        File[] files = folder.listFiles();
        
        for(int i=0; i<files.length; i++){
            if(files[i].getName().endsWith(".jpg") || files[i].getName().endsWith(".jpeg") || files[i].getName().endsWith(".png") || files[i].getName().endsWith(".bmp") || files[i].getName().endsWith(".JPG") || files[i].getName().endsWith(".JPEG") || files[i].getName().endsWith(".PNG") || files[i].getName().endsWith(".BMP")){
                listModel.addElement(files[i].getAbsolutePath());
                if(logger.isDebugEnabled()){
                    logger.info(files[i].getAbsolutePath());
                }
            }
        }
        AlbumList.setModel(listModel);
    }

    private void setThumbnail(JPanel panel, PlanarImage im) {
        Image img = adaptToParent(panel, im).getAsBufferedImage();
        JLabel label = new JLabel(new ImageIcon(img));
        JPanel ip = new JPanel();
        ip.setLayout(new BorderLayout());
        ip.add(label, BorderLayout.CENTER);   

        panel.removeAll();
        panel.setLayout(new BorderLayout());
        panel.add(ip, BorderLayout.WEST);
        panel.updateUI();
        panel.repaint();
    }

    private void InitializeCounters() {
        nUsers = IM.getConnectedUsers().size();
        nInbox = 0;
        nReq = 0;
    }

    private String[] parsePicture(ImageImpl im) {
        String txt;
        txt="<picture><id_picture>"+im.getID()+"</id_picture><properties><path>"+im.getPath()+"</path><description>"+im.getDescription()+"</description><format>"+im.getFormat()+"</format><id_user>1</id_user><creation_date><day>"+im.getDate().getDay()+"</day><month>"+im.getDate().getMonth()+"</month><year>"+im.getDate().getYear()+"</year></creation_date><size><value>"+im.getSize()+"</value><unit>"+im.getUnit()+"</unit></size><resolution><width>"+im.getResolution()[0]+"</width><height>"+im.getResolution()[1]+"</height></resolution></properties><tags>";
        int i = im.getKeywords().size();
        String k="";
        for(int j=0;j<i;j++){
            k="<keyword>"+im.getKeywords().get(j) +"</keyword>";
            txt += k;
        }
        txt = txt+"<ontologies><taxonomy><type>philospher</type><ontology>"+im.getOntology()+"</ontology></taxonomy></ontologies></tags></picture>";
        String[] out={txt};
        return out;
    }
}
